Visualizing UrbanScape

Okay... printing out the arrays and floats that represent the rent distribution of the UrbanScape worked for small sizes and rent values, but clearly we need a better way to visualize the UrbanScape. Let's make it more beautiful!


In [1]:
# Run the magic command that will plot all figures generated by the pylab package
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
# Import UrbanScape again
import UrbanScape.urbanscape as us

In [3]:
# Define the big UrbanScape, size = 20, rent = 100000, randomize = True
my_urbanscape = us.UrbanScape(20, 100000, randomize = True)

In [4]:
# Use the plot_urbanscape function to visualize your big urbanscape
us.plot_urbanscape(my_urbanscape)


Deep Dive

Isn't that so much better? Now that we can view much larger UrbanScapes, we can start our deep dive into the the different conditions that the UrbanScape module has to offer.

A key optional argument for us to play with is the gradient argument. This will modify the rent distribution in interesting ways so that we can see how different distributions affect the results of our model. It can take in 5 different string values:

'vertical', 'diagonal', 'random', 'CDB', 'BDquadrants'

In [ ]:
# Create an UrbanScape with these conditions
# size 20, rent 100000, randomize = True
# set gradient to each of the above values and plot the UrbanScape

Where are the Agents?

UrbanScape is an Agent-based Model, so now it's time to introduce you to the key ingredient in this particular model: The Food Providers. There are only two types of Food Providers in this model: FastFoodAgents and GroceryStoreAgents. To understand how they affect the UrbanScape, we need to add them to the environment.


In [5]:
# Create an UrbanScape 
# size = 20, rent = 100000, randomize = True
# set the create_rule to no_create_rule
my_urbanscape = us.UrbanScape(20, 100000, randomize = True, create_rule = us.no_create_rule)
my_urbanscape.step()

Create a FastFoodAgent


In [6]:
# Decide on the location of FastFoodAgent
location = (9,9)

# Create a fast food agent
fastfood_agent = us.FastFoodAgent(location, my_urbanscape)

In [7]:
# Add it to the UrbanScape
my_urbanscape.add_agent(fastfood_agent)
us.plot_urbanscape(my_urbanscape)



In [8]:
my_urbanscape.step()
us.plot_urbanscape(my_urbanscape)


Create a GroceryStoreAgent


In [9]:
# Decide on the location of GroceryStoreAgent
location2 = (5,5)

# Create a grocery store agent
grocery_store_agent = us.GroceryStoreAgent(location2, my_urbanscape)

# Add it to the UrbanScape
my_urbanscape.add_agent(grocery_store_agent)
my_urbanscape.step()

# Plot it
us.plot_urbanscape(my_urbanscape)